﻿Type.registerNamespace("SocialWidgetsContrib.Widgets.Socialbar");

SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner = function (element) {
    SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner.initializeBase(this, [element]);
}


SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner.prototype = {
    initialize: function () {
        SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner.callBaseMethod(this, 'initialize');

    },
    dispose: function () {
        SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner.callBaseMethod(this, 'dispose');
    },
    refreshUI: function () {
        var data = this._propertyEditor.get_control();
        jQuery("#UntitledPageTitle").val(data.UntitledPageTitle);
        jQuery("#ShowDelicious").attr('checked', data.ShowDelicious);
        jQuery("#ShowDigg").attr('checked', data.ShowDigg);
        jQuery("#ShowReddit").attr('checked', data.ShowReddit);
        jQuery("#ShowStumble").attr('checked', data.ShowStumble);
        jQuery("#ShowFacebook").attr('checked', data.ShowFacebook);
        jQuery("#ShowFurl").attr('checked', data.ShowFurl);
        jQuery("#ShowTwitter").attr('checked', data.ShowTwitter);
        jQuery("#ShowEmail").attr('checked', data.ShowEmail);

        this._clickRadioChoice("WindowOption", data.WindowOption);
    },
    applyChanges: function () {

        var controlData = this._propertyEditor.get_control();
        controlData.WindowOption = this._getSelectedChoice("WindowOption");

        controlData.UntitledPageTitle = jQuery("#UntitledPageTitle").val();
        controlData.ShowDelicious = jQuery("#ShowDelicious").attr('checked');
        controlData.ShowDigg = jQuery("#ShowDigg").attr('checked');
        controlData.ShowReddit = jQuery("#ShowReddit").attr('checked');
        controlData.ShowStumble = jQuery("#ShowStumble").attr('checked');
        controlData.ShowFacebook = jQuery("#ShowFacebook").attr('checked');
        controlData.ShowFurl = jQuery("#ShowFurl").attr('checked');
        controlData.ShowTwitter = jQuery("#ShowTwitter").attr('checked');
        controlData.ShowEmail = jQuery("#ShowEmail").attr('checked');

    },
    _getSelectedChoice: function (groupName) {
        return jQuery(this.get_element()).find("input[name='" + groupName + "']:checked").val();
    },
    _clickRadioChoice: function (groupName, value) {
        return jQuery(this.get_element()).find("input[name='" + groupName + "'][value='" + value + "']").click();
    }
}

SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner.registerClass('SocialWidgetsContrib.Widgets.Socialbar.SocialShareBarDesigner', Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase);
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();